package util;

public class BitArray {
	boolean[] bits;
	byte b;
	
	
	public BitArray(byte b, int size){
		bits = new boolean[size];
		this.b = b;
		for(int i = 0; i < size; i++)
			bits[size-1-i] = (b & (1 << i)) > 0; 
	}

	
	public String toString(){
		StringBuffer sb = new StringBuffer();
		sb.append("ByteValue: ");
		sb.append(b);
		sb.append("BitRepresentation: ");
		for(int i = 0; i < bits.length; i++){
			if(bits[i])sb.append("1");
			else sb.append("0");
		}
		return sb.toString();
		
	}
	
	public boolean get(int i){
		if(i < bits.length)
			return bits[i];
		else return false;
	}
}
